import React, { Component, useState, useEffect } from "react"
import { Button, Modal } from 'antd';
function App(props) {
    const [visible, setVisible] = useState(() => {
        return props.visible || false
    })
    const [confirmLoading, setConfirmLoading] = useState(false);
    const [modalText, setModalText] = useState('Content of the modal');
      const handleOk = () => {
        setModalText('The modal will be closed after two seconds');
        setTimeout(() => {
          setVisible(false);
          setConfirmLoading(false);
        }, 2000);
      };
      const handleCancel = () => {
        props.cancleClick()
      };
    return (
        <div>
            {/* <Button type="primary" onClick={showModal}>
                Open Modal with async logic
            </Button> */}
            <Modal
                title="Title"
                visible={visible}
                onOk={handleOk}
                confirmLoading={confirmLoading}
                onCancel={handleCancel}
            >
                <p>{modalText}</p>
            </Modal>
        </div>
    )
}


export default App